<?php	
	include_once $_SERVER['DOCUMENT_ROOT'] . "/config.php"; 
	
	global $cur_option; 
?>
						</section> <!-- -->
					</div> <!-- ym-cbox -->
				</div> <!-- ym-col1 -->
				<aside class="ym-col3">
					<!--<div class="ym-cbox">-->
						<div class="nav-wrapper">
							<nav class="ym-vlist">
								<h4 class="ym-vtitle">Menu</h4>
								<ul>
<?php
	include_once(ABS_PATH . "menu.php");
	
	menu($cur_option);
?>
								</ul>
							</nav>
						</div> <!-- nav-wrapper -->
					<div class="ym-cbox">
						<h4>Statistics</h4>
						<ul>
<?php
// Count tables

	try {
		$db = new PDO(PDO_PREFIX . SQLITE_DB_FILENAME);
	}	
	catch(PDOException $e)
	{
   		printf("\t<li>Database connect failed: %s</li>\n", $e->getMessage());
   		_log(__FILE__ . " - line " . __LINE__ . ": Error connecting to database: " . $e->getMessage());
	}

	try {
		$nRows = $db->query('select count(*) from Agents')->fetchColumn(); 
		echo "\t<li>\n\t";
		if ($nRows) 
			echo "Agents: " . $nRows;
		else
			echo "No Agents.";
		echo "\n\t</li>\n";
		
		$nRows = $db->query('select count(*) from Inventory')->fetchColumn(); 
		echo "\t<li>\n\t";
		if ($nRows) 
			echo "Inventory: " . $nRows;
		else
			echo "No Inventory.";
		echo "\n\t</li>\n";
		
		$nRows = $db->query('select count(*) from Positions')->fetchColumn(); 
		echo "\t<li>\n\t";
		if ($nRows) 
			echo "Positions: " . $nRows;
		else
			echo "No Positions.";
		echo "\n\t</li>\n";
		
		$nRows = $db->query('select count(*) from Obstacles')->fetchColumn(); 
		echo "\t<li>\n\t";
		if ($nRows) 
			echo "Obstacles: " . $nRows;
		else
			echo "No Obstacles.";
		echo "\n\t</li>\n";
	}
	catch(PDOException $e)
	{
   		printf("\t<li>Database connect failed; cannot execute queries: %s</li>\n", $e->getMessage());
   		_log(__FILE__ . " - line " . __LINE__ . ": Error executing queries in database: " . $e->getMessage());
	}	
?>
						</ul>
					</div> <!-- ym-cbox -->
				</aside>
			</div> <!-- ym-column -->
		</main>
		<footer>
			<p>Layout based on <a href="http://www.yaml.de/">YAML</a> with queries pushed to grid widget by <a href="http://www.trirand.com/blog/">jQuery UI Grid</a> and fonts by <a href="http://code.google.com/webfonts/">Google Font Directory</a>
			</p>
		</footer>
	</div>
</div>

<!-- full skip link functionality in webkit browsers -->
<script src="<?=ROOT_URL; ?>/yaml/core/js/yaml-focusfix.js"></script>
</body>
</html>